<?php

namespace Admin\Controller;
use Think\Controller;

class MemberController extends BaseController{
	
	public function index(){
		$nickname = I('nickname');
		if($nickname){
			$member = M('user');
			$count = $member->where("nickname like '%{$nickname}%'")->count();
			$page = new \Think\Page($count,10);
			$show = $page->show();
			$list = $member->where("nickname like '%{$nickname}%'")->limit($page->firstRow.','.$page->listRows)->order("id ASC")->select();
		}else{
			$member = M('user');
			$count = $member->count();
			$page = new \Think\Page($count,10);
			$show = $page->show();
			$list = $member->limit($page->firstRow.','.$page->listRows)->order("id ASC")->select();
		}
		
		$this->assign('show',$show);
		$this->assign('list',$list);
		$this->display();
	}
	
	public function disable(){
		$id = I('id');
		$res = M('user')->where("id = $id")->setField('status',0);
		if($res){
			$this->success('禁用成功！');
		}else{
			$this->error('禁用失败！');
		}
	}
	
	
	public function endisable(){
		$id = I('id');
		$res = M('user')->where("id = $id")->setField('status',1);
		if($res){
			$this->success('启用成功！');
		}else{
			$this->error('启用失败！');
		}
	}
	
}

?>